<?php


namespace app\operater\controller;


use think\Controller;
use think\facade\Session;

class Login extends Controller
{
    public function login()
    {
        if(request()->isAjax()){
            $param = request()->param();
            if(!captcha_check($param['verificationCode'])) return errorMsg("验证码不正确");
            $data = db("operation")->where('account',$param['account'])->find();
            if(empty($data)) return errorMsg("账号或密码不存在");
            $password = sha1(md5($param['password']));
            if($password != $data['password']) return errorMsg("账号或密码不存在");
            if($data['state'] != 0) return errorMsg("该账号存在异常");
            session("op_operation_id",$data['id']);
            return successMsg("正在登录请稍后...");
        }
        return view("login");
    }
    //退出
    public function logout()
    {
        Session::clear();
        $this->success("退出成功","/operater/login/login");
    }
}